package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TestSysNotice;
import com.ruoyi.system.service.ITestSysNoticeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 代码生成测试表Controller
 * 
 * @author ruoyi
 * @date 2025-09-11
 */
@Controller
@RequestMapping("/system/testsysnotice")
public class TestSysNoticeController extends BaseController
{
    private String prefix = "system/testsysnotice";

    @Autowired
    private ITestSysNoticeService testSysNoticeService;

    @RequiresPermissions("system:testsysnotice:view")
    @GetMapping()
    public String testsysnotice()
    {
        return prefix + "/testsysnotice";
    }

    /**
     * 查询代码生成测试表列表
     */
    @RequiresPermissions("system:testsysnotice:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TestSysNotice testSysNotice)
    {
        startPage();
        List<TestSysNotice> list = testSysNoticeService.selectTestSysNoticeList(testSysNotice);
        return getDataTable(list);
    }

    /**
     * 导出代码生成测试表列表
     */
    @RequiresPermissions("system:testsysnotice:export")
    @Log(title = "代码生成测试表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TestSysNotice testSysNotice)
    {
        List<TestSysNotice> list = testSysNoticeService.selectTestSysNoticeList(testSysNotice);
        ExcelUtil<TestSysNotice> util = new ExcelUtil<TestSysNotice>(TestSysNotice.class);
        return util.exportExcel(list, "代码生成测试表数据");
    }

    /**
     * 新增代码生成测试表
     */
    @RequiresPermissions("system:testsysnotice:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存代码生成测试表
     */
    @RequiresPermissions("system:testsysnotice:add")
    @Log(title = "代码生成测试表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TestSysNotice testSysNotice)
    {
        return toAjax(testSysNoticeService.insertTestSysNotice(testSysNotice));
    }

    /**
     * 修改代码生成测试表
     */
    @RequiresPermissions("system:testsysnotice:edit")
    @GetMapping("/edit/{noticeId}")
    public String edit(@PathVariable("noticeId") String noticeId, ModelMap mmap)
    {
        TestSysNotice testSysNotice = testSysNoticeService.selectTestSysNoticeByNoticeId(noticeId);
        mmap.put("testSysNotice", testSysNotice);
        return prefix + "/edit";
    }

    /**
     * 修改保存代码生成测试表
     */
    @RequiresPermissions("system:testsysnotice:edit")
    @Log(title = "代码生成测试表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TestSysNotice testSysNotice)
    {
        return toAjax(testSysNoticeService.updateTestSysNotice(testSysNotice));
    }

    /**
     * 删除代码生成测试表
     */
    @RequiresPermissions("system:testsysnotice:remove")
    @Log(title = "代码生成测试表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(testSysNoticeService.deleteTestSysNoticeByNoticeIds(ids));
    }
}
